package com.marketlive.app.b2c.account;

import com.marketlive.app.b2c.AbstractActionForm;
import com.sourcebeat.strutslive.common.PojoForm;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionMapping;
import org.marketlive.biz.session.context.ICommerceSession;
import org.marketlive.entity.account.IContact;
import org.marketlive.entity.account.ICustomer;
import org.marketlive.entity.account.IHint;

public class AccountRegisterForm extends AbstractActionForm
  implements PojoForm
{
  private static final long serialVersionUID = -3141030635301632504L;
  private static Log log = LogFactory.getLog(AccountRegisterForm.class);

  private String loginEmail = null;

  private String loginPassword = null;

  private String loginPasswordConfirm = null;

  private String hintQuestion = null;

  private String hintAnswer = null;
  private boolean contactModified;
  private boolean initialized;
  private String selectedContact;
  private IContact currentContact;
  private IContact billContact = null;
  private List contacts;
  private boolean isDoneWithRegistration = false;

  private boolean isReturningCustomerLoggedIn = false;

  private boolean isReturningCustomer = false;

  private boolean isShowingAddress = false;

  private ICommerceSession commerceSession = null;
  private boolean emailSignup;
  private String navigationMsg;
  private String navigationImage;
  private boolean showNavigation;
  private boolean requiredMsgShown;
  private boolean addressSaved;
  private boolean addressLoaded;
  private String firstNameSaved;
  private String lastNameSaved;
  private boolean addressListShown;
  private String currentPage;
  private boolean infoSaved;
  private boolean errorFound;
  private List payments;
  private List orderShipments;
  private List items;
  private List orderDiscounts;
  private String sourceCode;
  private boolean customerPlacedOrders;
  private List ordersByDate;
  private String userName;
  private boolean userFound;
  private String whence;
  private String recoveryPassword;
  private String recoveryEmail;
  private boolean passwordRecovered;
  private boolean passwordRecoveredEmailSent;
  private boolean hintShown;
  private String orderNumberPrefix;
  private String originalEmail;
  private String originalUserName;
  private boolean showOrderStatus;
  private boolean showOrderTracking;
  private String shipmentCarrierWxH;
  private boolean printReceipt;
  private int printWidthDelta;
  private String printReceiptPopupWxH;
  private IHint originalHint;

  public IHint getOriginalHint()
  {
    return this.originalHint;
  }

  public void setOriginalHint(IHint originalHint) {
    this.originalHint = originalHint;
  }

  public AccountRegisterForm()
  {
    log.debug("default constructor called");
  }

  public AccountRegisterForm(ICommerceSession commerceSession)
  {
    log.debug("constructor with session called");
    initialize(commerceSession);
  }

  public void initialize(ICommerceSession commerceSession)
  {
    this.commerceSession = commerceSession;
    this.initialized = true;
  }

  public boolean isInitialized()
  {
    return this.initialized;
  }

  public String getLoginEmail()
  {
    return this.loginEmail;
  }

  public void setLoginEmail(String loginEmail)
  {
    this.loginEmail = loginEmail;
  }

  public String getLoginPassword()
  {
    return this.loginPassword;
  }

  public void setLoginPassword(String loginPassword)
  {
    this.loginPassword = loginPassword;
  }

  public String getLoginPasswordConfirm()
  {
    return this.loginPasswordConfirm;
  }

  public void setLoginPasswordConfirm(String loginPasswordConfirm)
  {
    this.loginPasswordConfirm = loginPasswordConfirm;
  }

  public String getHintQuestion()
  {
    return this.hintQuestion;
  }

  public void setHintQuestion(String hintQuestion)
  {
    this.hintQuestion = hintQuestion;
  }

  public String getHintAnswer()
  {
    return this.hintAnswer;
  }

  public void setHintAnswer(String hintAnswer)
  {
    this.hintAnswer = hintAnswer;
  }

  public String getSelectedContact()
  {
    return this.selectedContact;
  }

  public void setSelectedContact(String selectedContact)
  {
    this.selectedContact = selectedContact;
  }

  public IContact getCurrentContact()
  {
    return this.currentContact;
  }

  public void setCurrentContact(IContact currentContact)
  {
    this.currentContact = currentContact;
  }

  public boolean isLoggedIn()
  {
    return this.commerceSession.isLoggedIn();
  }

  public boolean isGuest()
  {
    return this.commerceSession.isGuest();
  }

  public boolean isDoneWithRegistration()
  {
    return this.isDoneWithRegistration;
  }

  public void setDoneWithRegistration(boolean doneWithRegistration)
  {
    this.isDoneWithRegistration = doneWithRegistration;
  }

  public boolean isReturningCustomerLoggedIn()
  {
    return this.isReturningCustomerLoggedIn;
  }

  public void setReturningCustomerLoggedIn(boolean returningCustomerLoggedIn)
  {
    this.isReturningCustomerLoggedIn = returningCustomerLoggedIn;
  }

  public boolean isReturningCustomer()
  {
    return this.isReturningCustomer;
  }

  public IContact getBillContact()
  {
    return this.billContact;
  }

  public void setBillContact(IContact billContact) {
    this.billContact = billContact;
  }

  public ICustomer getCustomer()
  {
    return this.commerceSession.getCustomer();
  }

  public boolean isAddressListShown()
  {
    return this.addressListShown;
  }

  public void setAddressListShown(boolean addressListShown)
  {
    this.addressListShown = addressListShown;
  }

  public boolean isAddressLoaded()
  {
    return this.addressLoaded;
  }

  public void setAddressLoaded(boolean addressLoaded)
  {
    this.addressLoaded = addressLoaded;
  }

  public boolean isAddressSaved()
  {
    return this.addressSaved;
  }

  public void setAddressSaved(boolean addressSaved)
  {
    this.addressSaved = addressSaved;
  }

  public List getContacts()
  {
    return this.contacts;
  }

  public void setContacts(List contacts)
  {
    this.contacts = contacts;
  }

  public String getCurrentPage()
  {
    return this.currentPage;
  }

  public void setCurrentPage(String currentPage)
  {
    this.currentPage = currentPage;
  }

  public boolean isCustomerPlacedOrders()
  {
    return this.customerPlacedOrders;
  }

  public void setCustomerPlacedOrders(boolean customerPlacedOrders)
  {
    this.customerPlacedOrders = customerPlacedOrders;
  }

  public boolean isEmailSignup()
  {
    return this.emailSignup;
  }

  public void setEmailSignup(boolean emailSignup)
  {
    this.emailSignup = emailSignup;
  }

  public boolean isErrorFound()
  {
    return this.errorFound;
  }

  public void setErrorFound(boolean errorFound)
  {
    this.errorFound = errorFound;
  }

  public String getFirstNameSaved()
  {
    return this.firstNameSaved;
  }

  public void setFirstNameSaved(String firstNameSaved)
  {
    this.firstNameSaved = firstNameSaved;
  }

  public boolean isHintShown()
  {
    return this.hintShown;
  }

  public void setHintShown(boolean hintShown)
  {
    this.hintShown = hintShown;
  }

  public boolean isInfoSaved()
  {
    return this.infoSaved;
  }

  public void setInfoSaved(boolean infoSaved)
  {
    this.infoSaved = infoSaved;
  }

  public boolean isShowingAddress()
  {
    return this.isShowingAddress;
  }

  public void setShowingAddress(boolean isShowingAddress)
  {
    this.isShowingAddress = isShowingAddress;
  }

  public List getItems()
  {
    return this.items;
  }

  public void setItems(List items)
  {
    this.items = items;
  }

  public String getLastNameSaved()
  {
    return this.lastNameSaved;
  }

  public void setLastNameSaved(String lastNameSaved)
  {
    this.lastNameSaved = lastNameSaved;
  }

  public String getNavigationImage()
  {
    return this.navigationImage;
  }

  public void setNavigationImage(String navigationImage)
  {
    this.navigationImage = navigationImage;
  }

  public String getNavigationMsg()
  {
    return this.navigationMsg;
  }

  public void setNavigationMsg(String navigationMsg)
  {
    this.navigationMsg = navigationMsg;
  }
  
  public List getOrderDiscounts()
  {
    return this.orderDiscounts;
  }

  public void setOrderDiscounts(List orderDiscounts)
  {
    this.orderDiscounts = orderDiscounts;
  }

  public String getOrderNumberPrefix()
  {
    return this.orderNumberPrefix;
  }

  public void setOrderNumberPrefix(String orderNumberPrefix)
  {
    this.orderNumberPrefix = orderNumberPrefix;
  }

  public List getOrdersByDate()
  {
    return this.ordersByDate;
  }

  public void setOrdersByDate(List ordersByDate)
  {
    this.ordersByDate = ordersByDate;
  }

  public List getOrderShipments()
  {
    return this.orderShipments;
  }

  public void setOrderShipments(List orderShipments)
  {
    this.orderShipments = orderShipments;
  }

  public String getOriginalEmail()
  {
    return this.originalEmail;
  }

  public void setOriginalEmail(String originalEmail)
  {
    this.originalEmail = originalEmail;
  }

  public String getOriginalUserName()
  {
    return this.originalUserName;
  }

  public void setOriginalUserName(String originalUserName)
  {
    this.originalUserName = originalUserName;
  }

  public boolean isPasswordRecovered()
  {
    return this.passwordRecovered;
  }

  public void setPasswordRecovered(boolean passwordRecovered)
  {
    this.passwordRecovered = passwordRecovered;
  }

  public boolean isPasswordRecoveredEmailSent()
  {
    return this.passwordRecoveredEmailSent;
  }

  public void setPasswordRecoveredEmailSent(boolean passwordRecoveredEmailSent)
  {
    this.passwordRecoveredEmailSent = passwordRecoveredEmailSent;
  }

  public List getPayments()
  {
    return this.payments;
  }

  public void setPayments(List payments)
  {
    this.payments = payments;
  }

  public String getRecoveryEmail()
  {
    return this.recoveryEmail;
  }

  public void setRecoveryEmail(String recoveryEmail)
  {
    this.recoveryEmail = recoveryEmail;
  }

  public String getRecoveryPassword()
  {
    return this.recoveryPassword;
  }

  public void setRecoveryPassword(String recoveryPassword)
  {
    this.recoveryPassword = recoveryPassword;
  }

  public boolean isRequiredMsgShown()
  {
    return this.requiredMsgShown;
  }

  public void setRequiredMsgShown(boolean requiredMsgShown)
  {
    this.requiredMsgShown = requiredMsgShown;
  }

  public boolean isShowNavigation()
  {
    return this.showNavigation;
  }

  public void setShowNavigation(boolean showNavigation)
  {
    this.showNavigation = showNavigation;
  }

  public String getSourceCode()
  {
    return this.sourceCode;
  }

  public void setSourceCode(String sourceCode)
  {
    this.sourceCode = sourceCode;
  }

  public boolean isUserFound()
  {
    return this.userFound;
  }

  public void setUserFound(boolean userFound)
  {
    this.userFound = userFound;
  }

  public String getUserName()
  {
    return this.userName;
  }

  public void setUserName(String userName)
  {
    this.userName = userName;
  }

  public String getWhence()
  {
    return this.whence;
  }

  public void setWhence(String whence)
  {
    this.whence = whence;
  }

  public void setReturningCustomer(boolean isReturningCustomer)
  {
    this.isReturningCustomer = isReturningCustomer;
  }

  public boolean isShowOrderStatus()
  {
    return this.showOrderStatus;
  }

  public void setShowOrderStatus(boolean showOrderStatus)
  {
    this.showOrderStatus = showOrderStatus;
  }

  public boolean isShowOrderTracking()
  {
    return this.showOrderTracking;
  }

  public void setShowOrderTracking(boolean showOrderTracking)
  {
    this.showOrderTracking = showOrderTracking;
  }

  public String getShipmentCarrierWxH()
  {
    return this.shipmentCarrierWxH;
  }

  public void setShipmentCarrierWxH(String shipmentCarrierWxH)
  {
    this.shipmentCarrierWxH = shipmentCarrierWxH;
  }

  public boolean isPrintReceipt()
  {
    return this.printReceipt;
  }

  public void setPrintReceipt(boolean printReceipt)
  {
    this.printReceipt = printReceipt;
  }

  public int getPrintWidthDelta()
  {
    return this.printWidthDelta;
  }

  public void setPrintWidthDelta(int printWidthDelta)
  {
    this.printWidthDelta = printWidthDelta;
  }

  public String getPrintReceiptPopupWxH()
  {
    return this.printReceiptPopupWxH;
  }

  public void setPrintReceiptPopupWxH(String printReceiptPopupWxH)
  {
    this.printReceiptPopupWxH = printReceiptPopupWxH;
  }

  public boolean isContactModified()
  {
    return this.contactModified;
  }

  public void setContactModified(boolean contactModified)
  {
    this.contactModified = contactModified;
  }

  public void resetState()
  {
    try
    {
      setCurrentContact(null);
      setSelectedContact(null);
      setReturningCustomerLoggedIn(false);
      setDoneWithRegistration(false);
      setReturningCustomer(false);
      setReturningCustomerLoggedIn(false);
      setShowingAddress(false);
      setAddressListShown(true);
      setAddressSaved(false);
      setFirstNameSaved(null);
      setLastNameSaved(null);
      setLoginPasswordConfirm("");
      setAction("init");
      this.commerceSession.logout();
    } catch (Exception e) {
      log.debug("Exception: " + e);
    }
  }

  public void reset(ActionMapping mapping, HttpServletRequest request)
  {
    try
    {
      super.reset(mapping, request);
      if (("submit".equals(request.getParameter("method"))) && (
        (this.currentContact != null) || (getBillContact() != null)))
        setLoginPasswordConfirm("");
    }
    catch (Exception e)
    {
      log.debug("Exception: " + e);
    }
  }
}